Sway Language Server
This extension provides LSP support for the Sway smart contract programming language.
Features
- go-to type definition
- types and documentation on hover
- inlay hints for types and parameter names
- semantic syntax highlighting
- symbol renaming
- code actions
- imports insertion
Coming Soon
- code completion
- apply suggestions from errors
- find all references, workspace symbol search
- ... and many more
Quick start
- Install the Fuel toolchain.
- Ensure
forc-lsp
is installed correctly by enteringforc-lsp --version
into your terminal. - Install the Sway VSCode plugin.
Trying out the local version
To try out the local LSP version:
- Install the local version of the server:
cargo install --path ./forc-plugins/forc-lsp
. - Open VSCode settings and set the
Sway-lsp › Diagnostic: Bin Path
to the installedforc-lsp
binary. The path to the binary will be listed at the end of thecargo install
command and is usually:/home/<user>/.cargo/bin/forc-lsp
. - Open an arbitrary Sway project. E.g.,
./examples/arrays
. - Open the Output window in VSCode and select Sway Language Server from the drop down menu.
- Start coding and observe the LSP output in the Output window. This window will also show any
dbg!
oreprintln!
lines.